﻿using System;
using System.Collections.Generic;
using UnityEngine;

// Token: 0x0200020B RID: 523
internal class InterceptionCalculator
{
	// Token: 0x06000B0A RID: 2826 RVA: 0x0005D5F4 File Offset: 0x0005B7F4
	public static Vector2 CalculateInterceptionCourse(Vector2 target, Vector2 targetSpeed, Vector2 self, Vector2 selfSpeed)
	{
		List<InterceptionCalculator.TimePosition> list = new List<InterceptionCalculator.TimePosition>();
		for (float num = 0f; num < 5f; num += 1f)
		{
			InterceptionCalculator.TimePosition timePosition = new InterceptionCalculator.TimePosition();
			Vector2 position = target + targetSpeed * num;
			timePosition.time = num;
			timePosition.position = position;
			list.Add(timePosition);
		}
		int index = 0;
		float num2 = float.MaxValue;
		float num3 = num2;
		for (int i = 0; i < list.Count; i++)
		{
			InterceptionCalculator.TimePosition timePosition2 = list[i];
			for (float num4 = 0f; num4 < 5f; num4 += 1f)
			{
				float num5 = Vector2.Distance(self, timePosition2.position) / 1f;
				float num6 = Mathf.Abs(num5 - timePosition2.time);
				if (num6 < num2)
				{
					num3 = (num2 = num6);
					index = i;
				}
				else if (num6 > num3)
				{
					return list[index].position;
				}
			}
		}
		return list[index].position;
	}

	// Token: 0x0400101F RID: 4127
	[SerializeField]
	private const float SecondsAhead = 5f;

	// Token: 0x04001020 RID: 4128
	[SerializeField]
	private const float SecondsRate = 1f;

	// Token: 0x0200020C RID: 524
	private class TimePosition
	{
		// Token: 0x04001021 RID: 4129
		public float time;

		// Token: 0x04001022 RID: 4130
		public Vector2 position;
	}
}
